package studychinese.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public abstract class BaseFragment extends Fragment {
    protected View rootView;
    protected Activity mActivity;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mActivity = getActivity();

        rootView = initView(inflater, container, savedInstanceState);

        return rootView;
    }

    /**
     * @return
     */
    protected abstract View initView(LayoutInflater inflater, ViewGroup container,
                                     Bundle savedInstanceState);

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        loadData();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        registerReceiver();
        registerEventBus();
    }

    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void onPause() {
        super.onPause();

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        destoryReceiver();
        destoryEventBus();

    }

    /**
     *
     */
    protected void loadData() {

    }

    /**
     * 注册广播
     */
    public void registerReceiver() {
    }

    /**
     * 销毁广播
     */
    public void destoryReceiver() {
    }

    /**
     * 注册eventbus
     */
    public void registerEventBus() {
    }

    /**
     * 销毁eventBus
     */
    public void destoryEventBus() {
    }


}
